﻿<%@ page language="java" errorPage="/common/error.jsp" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" %>
<%@ page isELIgnored="false" %>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="SHORTCUT ICON" href="assets/images/favicon.ico" type="image/x-icon"/>
<title>端泉后台管理系统</title>
<link href="<c:url value='/assets/style/adminLogin.css'/>" rel="stylesheet" type="text/css" />
<!-- jQuery Start -->
<script type="text/javascript" src="<c:url value='/assets/js/jQuery/jquery.js'/>"></script>
<script type="text/javascript" src="<c:url value='/assets/js/jQuery/jquery.form.js'/>"></script>
<!-- jQuery End -->
<script type="text/javascript">
if(self!=top){top.location=self.location;}
// <![CDATA[
$(document).ready(function() {
   var options = { beforeSubmit: validate, success: showResponse }; 
   
    $('#loginForm').submit(function() { 
        $(this).ajaxSubmit(options); 
        return false; 
    }); 
	
	$("#codeImg").click(function(){
		refreshCodeImg();
	})
});
//refresh code
function refreshCodeImg(){
	$("#codeImg").attr("src","<c:url value='/code.html'/>?now="+ new Date());
}
function validate(formData, jqForm, options) { 
	var userName = $("#userName").val(); 
    var password = $("#password").val(); 
	var code = $("#code").val(); 
	
	if($.trim(userName) == ""){
		$("#infoSpan").html("<img src='<c:url value='/assets/images/warn.gif'/>'>请输入帐户!");	
		$("#userName").focus();
		return false;
	}
    if ($.trim(password) == "") { 
        $("#infoSpan").html("<img src='<c:url value='/assets/images/warn.gif'/>'>请输入密码!");
		$("#password").focus();
        return false; 
    } 
	
	if ($.trim(code) == "") { 
        $("#infoSpan").html("<img src='<c:url value='/assets/images/warn.gif'/>'>请输入验证码!");
		$("#code").focus();
        return false; 
    }
	
	$("#infoSpan").html("<img src='<c:url value='/assets/images/load.gif'/>'>正在登录...");
}
// post-submit callback 
function showResponse(responseText, statusText, xhr, $form)  { 
	if(responseText=="success"){
		$("#infoSpan").html("登陆成功...");
		window.location.href="<c:url value='/admin/index.jsp'/>";
	} else if(responseText=="errorCode"){
		$("#infoSpan").html("<img src='<c:url value='/assets/images/warn.gif'/>'>登录失败,验证码不正确!");
	}else if(responseText=="errorPassword"){
		$("#infoSpan").html("<img src='<c:url value='/assets/images/warn.gif'/>'>登录失败,帐户不正确!");
	}else if(responseText=="error") {
		$("#infoSpan").html("<img src='<c:url value='/assets/images/warn.gif'/>'>系统错误,登陆失败!");
	}else if(responseText=="errorStatus") {
		$("#infoSpan").html("<img src='<c:url value='/assets/images/warn.gif'/>'>登录失败,该用户已经被禁用!");
	}
	refreshCodeImg();
} 
// ]]>
</script>
</head>

<body>
<form action="<c:url value='/adminLogin.ac'/>" method="post" name="loginForm" id="loginForm" >
<table width="409" border="0" align="center" cellpadding="0" cellspacing="0" class="top_height">
  <tr>
    <td><img src="<c:url value='/assets/images/myportal_top.png'/>" width="409" height="76" /></td>
  </tr>
  <tr>
    <td height="153" valign="top" background="<c:url value='/assets/images/myportal_bg.png'/>">
    <table width="409" border="0" cellpadding="0" cellspacing="0" class="login_table">
      <tr>
        <td height="26" colspan="3" align="center"><span id="infoSpan" class="infoSpan">
            <c:if test="${not empty requestScope.message}"><c:out value="${requestScope.message}" escapeXml="false"/></c:if>
            &nbsp;</span></td>
        </tr>
      <tr>
        <td width="94" height="26" align="right">帐&nbsp;&nbsp;&nbsp;&nbsp;户:</td>
        <td width="10">&nbsp;</td>
        <td width="309" align="left"><input name="userName" type="text" class="input_bg" id="userName" value="admin" /></td>
      </tr>
      <tr>
        <td height="26" align="right">密&nbsp;&nbsp;&nbsp;&nbsp;码:</td>
        <td>&nbsp;</td>
        <td align="left"><input name="password" type="password" class="input_bg" id="password" value="admin"/></td>
      </tr>
      <tr>
        <td height="26" align="right">验证码:</td>
        <td>&nbsp;</td>
        <td align="left">
          <table width="197" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="42"><input name="code" type="text" class="code_input" id="code" size="8" value=""/></td>
              <td width="155" align="center"><img src="<c:url value='/code.html'/>" id="codeImg" title="点击修改" style="cursor:pointer;border-color:#000" border="1"/></td>
            </tr>
          </table></td>
      </tr>
      <tr>
        <td height="37" align="right">&nbsp;</td>
        <td>&nbsp;</td>
        <td align="left" valign="bottom"><input type="image" src="<c:url value='/assets/images/login.png'/>" width="62" height="23" onmouseover="this.src='<c:url value='/assets/images/login_over.png'/>'" onmouseout="this.src='<c:url value='/assets/images/login.png'/>'" style="cursor:pointer"/>&nbsp;&nbsp;<img src="<c:url value='/assets/images/cancle.png'/>" width="62" height="23" onmouseover="this.src='<c:url value='/assets/images/cancle_over.png'/>'" onmouseout="this.src='<c:url value='/assets/images/cancle.png'/>'" onclick="document.loginForm.reset()" style="cursor:pointer"/></td>
      </tr>
    </table></td>
  </tr>
</table>
</form>
<script language="JavaScript" type="text/javascript">
  <!--
 if (document.forms["loginForm"].elements["userName"].type != "hidden")
    document.forms["loginForm"].elements["userName"].focus()
  // -->
</script>
</body>
</html>
